package com.sny.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @Author: Administrator
 * @Description: 所有实体基类
 * @Date: 2020-05-26 08:44
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseModel implements Serializable {
    private static final long serialVersionUID = -7452428427642412626L;
    @Id
    @GeneratedValue(generator = "system-uuid")
    /**uuid2,uuid,uuid.hex,guid//DefaultIdentifierGeneratorFactory*/
    @GenericGenerator(name = "system-uuid", strategy = "uuid2")
    @Column(name = "id", nullable = false)
    private String id;
    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "create_time", updatable = false)
    private Date createTime;
    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "update_time")
    private Date updateTime;

    /**
     * 创建者
     */
    @Column(name = "created_by")
    @CreatedBy
    private String createdBy;
    /**
     * 更新者
     */
    @Column(name = "update_by")
    @LastModifiedBy
    private String updateBy;
    /**
     * 删除标识 0---正常 1---删除
     */
    @Column(length = 1)
    private Integer flag = 0;
    /**
     * 排序
     */
    @Column(length = 2)
    private Integer sort = 0;
    /**
     * 状态
     */
    @Column(length = 2)
    private Integer status = 0;
    /**
     * 版本
     */
    @Version
    @Column(name = "version")
    private Integer version = 0;
    /**
     * 是否屏蔽 0--可用  1--屏蔽
     */
    @Column(name = "shield")
    private Integer shield = 0;
}
